package katas.dynamic;

public class FibonacciCalculator {

	public int calcualteFibonacci(int n){
		if(n==0)
			return 0;
		if(n==1)
			return 1;
		return calcualteFibonacci(n-1) + calcualteFibonacci(n-2);
	}
	
	public int calcualteFibonacci2(int n){
		if(n==0)
			return 0;
		if(n==1)
			return 1;
		
		int[] f = {0,1,1};
		for(int i=2; i<=n; i++){
			f[2] = f[0] + f[1];
			f[0] = f[1];
			f[1] = f[2];
		}
		return f[2];
	}
	
	public static void main(String[] args) {
		FibonacciCalculator fibonacciCalculator = new FibonacciCalculator();
		for(int i = 0; i<100; i++){
			System.out.println(fibonacciCalculator.calcualteFibonacci(i) == fibonacciCalculator.calcualteFibonacci2(i));
		}
	}
}
